Separate DB almost fixed
[RRRRHHHH_Code] / ruralHouses client / src / gui / ModifyOfferGUI.java
index d5422bf..73230bb 100644 (file)
@@ -91,7 +91,7 @@ public class ModifyOfferGUI extends JFrame {
                        e1.printStackTrace();
                }
 
-               
+
                jComboBox1 = new JComboBox<RuralHouse>(Hlist);
 
                comboBox_o = new JComboBox<Offer>(
@@ -146,11 +146,11 @@ public class ModifyOfferGUI extends JFrame {
 
                        @Override
                        public void itemStateChanged(ItemEvent arg0) {
+
                                Vector<Offer> vo= null;
                                try {
                                        vo = om.getRuralHouseOffers((RuralHouse) jComboBox1.getSelectedItem());
                                } catch (RemoteException e) {
-                                       // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }
                                comboBox_o.removeAllItems();
@@ -252,7 +252,28 @@ public class ModifyOfferGUI extends JFrame {
                                }
                        }
                });
-
+               if(((Offer) comboBox_o.getSelectedItem()).isBooked()){
+                       jLabel5.setText("This offer is already booked.");
+                       jButton1.setEnabled(false);                                     
+               }
+               comboBox_o.addItemListener(new ItemListener() {
+                       @Override
+                       public void itemStateChanged(ItemEvent arg0) {
+                               if(((Offer) comboBox_o.getSelectedItem()).isBooked()){
+                                       jLabel5.setText("This offer is already booked.");
+                                       jButton1.setEnabled(false);                                     
+                               }
+                       }
+               });
+               comboBox_o.addItemListener(new ItemListener() {
+                       @Override
+                       public void itemStateChanged(ItemEvent arg0) {
+                               if(!((Offer) comboBox_o.getSelectedItem()).isBooked()){
+                                       jLabel5.setText("");;
+                                       jButton1.setEnabled(true);                                      
+                               }
+                       }
+               });
                this.getContentPane().add(jCalendar2, null);
                this.getContentPane().add(jCalendar1, null);
                this.getContentPane().add(jLabel5, null);